/*
 * @Author: Tendo 
 * @Date: 2021-08-27 17:42:12 
 * @param {number[]} nums
 * @param {number} val
 * @return {number}
 */
//时间复杂度O(n)
//空间复杂度O(1)
var removeElement = (nums, val) => {
    let k = 0;
    for (let i = 0; i < nums.length; i++) {
        if (nums[i] != val) {
            nums[k++] = nums[i]
        }
    }
    return k;
};